package backend.service.charisma;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import shared.exceptions.CharismaConnectionDownException;

@Service
public class CharismaValidatorScheduledJob {
    private static Logger logger = Logger.getLogger(CharismaValidatorScheduledJob.class);

    @Autowired
    private CharismaDataSynchronizer charismaDataSynchronizer;

    public void runValidation() {
        logger.info("Performing synchronization and validation against Charisma service ... ");
        try {
            charismaDataSynchronizer.validateYesterdayHoursForAllEmployees();
        } catch (CharismaConnectionDownException ccde) {
            logger.info(ccde.getMessage() + " Please contact the Charisma system administrator.");
        }
    }
}